﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "GalleryDefinitionReference.h"
#include "GbmpNew.h"
#include "ControlDefinitionChangeEvent.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

namespace gcmp
{

    GalleryDefinitionReference::GalleryDefinitionReference(GalleryDefinition* pGalleryDefinition)
        :m_wpGalleryDefinition(pGalleryDefinition)
    {

    }

    GalleryDefinitionReference::~GalleryDefinitionReference()
    {

    }

    int GalleryDefinitionReference::GetItemWidth() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, 0, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetItemWidth();
    }

    int GalleryDefinitionReference::GetItemHeight() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, 0, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetItemHeight();
    }

    bool GalleryDefinitionReference::SetCurrentGalleryItem(const std::wstring& id)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->SetCurrentGalleryItem(id);
    }

    void GalleryDefinitionReference::SetCurrentIndex(int index)
    {
        DBG_WARN_AND_RETURN_VOID_UNLESS(m_wpGalleryDefinition, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        m_wpGalleryDefinition->SetCurrentIndex(index);
    }

    int GalleryDefinitionReference::GetCurrentIndex() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, 0, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetCurrentIndex();
    }

    bool GalleryDefinitionReference::SetColumnCount(int columnCount)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->SetColumnCount(columnCount);
    }

    int GalleryDefinitionReference::GetColumnCount() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, 0, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetColumnCount();
    }

    const gcmp::IGalleryItemDefinition* GalleryDefinitionReference::GetCurrentItem() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, nullptr, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetCurrentItem();
    }

    gcmp::IGalleryItemDefinition* GalleryDefinitionReference::GetItem(int index) const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, nullptr, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return  m_wpGalleryDefinition->GetItem(index);
    }

    gcmp::IGalleryItemDefinition* GalleryDefinitionReference::GetItem(const std::wstring& id) const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, nullptr, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetItem(id);
    }

    int GalleryDefinitionReference::GetItemIndex(const std::wstring& id) const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, -1, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetItemIndex(id);
    }

    bool GalleryDefinitionReference::InsertItem(const std::wstring& beforeId, const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip, const std::wstring& iconPath, const Any& userData)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->InsertItem(beforeId, id, caption, tooltip, iconPath, userData);
    }

    bool GalleryDefinitionReference::DeleteItem(const std::wstring& id)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->DeleteItem(id);
    }

    bool GalleryDefinitionReference::DeleteAllItems()
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->DeleteAllItems();
    }

    gcmp::IGalleryEvent* GalleryDefinitionReference::GetEvent() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, nullptr, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetEvent();
    }

    gcmp::IControlDefinitionChangeEvent* GalleryDefinitionReference::GetControlDefinitionChangeEvent() const
    {
        if (m_wpGalleryDefinition)
        {
            return m_wpGalleryDefinition->GetControlDefinitionChangeEvent();
        }
        return nullptr;
    }

    std::wstring GalleryDefinitionReference::GetId() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, L"", L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetId();
    }

    std::wstring GalleryDefinitionReference::GetCaption() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, L"", L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetCaption();
    }

    std::wstring GalleryDefinitionReference::GetTooltip() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, L"", L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetTooltip();
    }

    bool GalleryDefinitionReference::IsVisible() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->IsVisible();
    }

    bool GalleryDefinitionReference::IsEnabled() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->IsEnabled();
    }

    std::vector<IGalleryItemDefinition*> GalleryDefinitionReference::GetAllItems() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, std::vector<IGalleryItemDefinition*>(), L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->GetAllItems();
    }

    bool GalleryDefinitionReference::AddItem(const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip, const std::wstring& iconPath, const Any& userData)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpGalleryDefinition, false, L"m_wpGalleryDefinition为空",L"GDMPLab",L"2024-03-30");
        return m_wpGalleryDefinition->AddItem(id, caption, tooltip, iconPath, userData);
    }

}